package cn.com.joycode.nimble.core.message;

import cn.com.joycode.nimble.core.lang.AbstractNbObject;
import cn.com.joycode.nimble.core.utils.SnowflakeUtil;
import cn.hutool.core.date.DateUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @author Max Woods
 */

@Getter
@Setter
public class NbMsgHeader extends AbstractNbObject {

    private long id;

    private String spec;

    private String ver;

    private NbMsgType type;

    private String utc;

    private Date timestamp;

    private Long ref;

    private String clientIp;

    private String signature;

    public NbMsgHeader() {
        this(null, null);
    }

    public NbMsgHeader(String spec, String ver) {
        this(NbMsgType.NORMAL, spec, ver);
    }

    public NbMsgHeader(NbMsgType type, String spec, String ver) {
        id = SnowflakeUtil.nextId();
        this.type = type;
        this.spec = spec;
        this.ver = ver;
        timestamp = new Date();
        utc = DateUtil.format(timestamp, "yyyy-MM-dd'T'HH:mm:ss.SSSZZ");
    }
}
